// /store/index.js
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
        driverobj: uni.getStorageSync('driverobj'),
        readSeconds: undefined,
        // userId:uni.getStorageSync('userId'),
        // location: null
    },
    mutations: {
        driverfun(state, obj) {
            state.driverobj = obj
            console.log(state.driverobj);
            uni.setStorageSync('driverobj', state.driverobj)
        },
        setReadSeconds(state, obj) {
            state.readSeconds = obj
        }
        // loguserId(state,obj) {
        //  state.userId=obj
        //  console.log(state.userId);
        //  uni.setStorageSync('userId',state.userId)
        // },
        // setLocation(state, location) {
        //       state.location = location
        //     }
    },
    actions: {
        //   async getLocation({ commit }) {
        //     try {
        //       const res = await uni.getLocation({
        // 	type: 'gcj02',
        // 	isHighAccuracy: true,

        // });
        //       commit('setLocation', res)
        // console.log(res,'index.js');
        //     } catch (error) {
        //       console.error('获取位置信息失败:', error)
        //     }
        //   }
    }
})

export default store